package com.springmvc.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {

    /**
     * 跳转到登录界面
     * @return
     */
    @RequestMapping("/login")
    public String login(){
        return "login";
    }

    @RequestMapping(value = "/doLogin")
    public String doLogin(String userName, String password, HttpSession session){
        if("admin".equals(userName) && "123456".equals(password)){
            session.setAttribute("userName",userName);
            session.setAttribute("password",password);
            return "home";
        }
        return "error";
    }

}
